package com.tree.thrive.business.common.po.domain.bo;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Auther: cheng.tang
 * @Date: 2023/5/25
 * @Description: top-tree
 */
@Slf4j
public class OuterClassBO {

    private class PrivateInnerClass {
        private void sayHello() {
            String msg = "Hello from private inner class!";
            System.out.println(msg);
            log.info(msg);
        }
    }


    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        OuterClassBO outer = new OuterClassBO();
        PrivateInnerClass privateInner = outer.new PrivateInnerClass();

        // 使用反射调用私有内部类的方法
        Method method = PrivateInnerClass.class.getDeclaredMethod("sayHello");
        method.setAccessible(true);
        method.invoke(privateInner);
    }


}
